//function checkNameAndPwd() {

	//获取控件内容
	//var username = document.getElementById("username_input").value;
	//var userpsw = document.getElementById("userpsw_input").value;
	//console.log("username = "  + username);
	//console.log("userpsw = "  + userpsw);

	////假装此处有数据库
	//var usernames=new Array("Mike","Sarah","Alice", "B", "MYX");
	//var userpsws = new Array("123456", "654321", "8888", "5555", "777");
	////数据校验
    //
	//var t;
	//for (var i = 0; i < 5; i ++) {
	//	if (usernames[i] == username) {
	//		t = i; break;
	//	}
	//}
    //
	//if (t != undefined && userpsws[t] == userpsw) {
	//	console.log("登录成功， 跳转页面！");
	//	window.location.href="shopping_cart2.html";
	//} else {
	//	console.log("用户名不存在或者密码不匹配！");
	//}

	////数据库实例
	const db = require('./dbhelper');

	//查询所有数据
	db.query('SELECT Userid,UserName,UserPassword,UserItem,UserAddress FROM user', [], function(result, fields) {
		console.log('查询结果：');
		console.log(result);
	});

	////根据输入的用户名查询密码的sql语句
	//var sql_str = "SELECT UserPassword FROM user WHERE UserName = '" + username + "'";
	var sql_str = "SELECT UserPassword FROM user WHERE UserName = 'Mike' ";


	db.query(sql_str, [], function(res, fields) {
		console.log('查询结果：');
		var password = res[0].UserPassword;
		console.log("查到的密码为：" + password);
		//if (password != undefined && password == userpsw)
		if (password != undefined && password == 123456) {
			console.log("登录成功， 跳转页面！");
			window.location.href="shopping_cart2.html";
		} else {
			console.log("用户名不存在或者密码不匹配！");
		}
	});


	//////添加实例
	////var addSql = 'INSERT INTO websites(id,name,url,alexa,country) VALUES(0,?,?,?,?)';
	////var addSqlParams = ['汪政', 'https://www.baidu.com','23453', 'CN'];
	////db.query(addSql, addSqlParams, function(result, fields) {
	////	console.log('添加成功')
	////})

//}